<extend name="Index:base" />
<block name="title"><title>会员管理</title></block>
<block name="style">
 <style>
.main,.panel-default>.panel-heading{
background:none;
}

body{
background:none;
}
.panel.panel-default,.panel .panel-body,.panel .panel-heading,.table-bordered {
	border:none;
}
.table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
	border:none;		
	padding:15px;	
	line-height:8px;
	height: 8px;
	border-top: 1px solid #d4d4d4;
	border-bottom: 1px solid #d4d4d4;
}
.name strong{
color:#000000;
font-size:15px;
font-weight:600;
}
.name {
	color:#20a8d8;
	font-size:12px;
}
.smallfont {
	color:#9c9c9c;
	font-size:12px;
}

.align-center{
	text-align:center; 
}
.title2{
text-align:center;
}
.table-bordered > tbody > tr .wd{
	text-align:left;	
}

.col-xs-2,.col-xs-4{
padding-right:0;
margin:10px 0;
}
 </style>
</block>
	<!-- start: Header -->
<block name="body">

			<!-- end: Main Menu -->
						
		<!-- start: Content -->
		<div class="main ">
		
			<div class="row">
				<div class="col-lg-12">
					<h3 class="page-header"><i class="fa fa-life-bouy"></i>会员管理</h3>
				</div>
			</div>

			<div class="row">		
				<div class="col-lg-12">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h2><span class="break"></span><strong>会员管理</strong></h2>&nbsp;&nbsp;&nbsp;
							<a class="btn btn-success" role="button" data-toggle="modal" href="#again" id="add_right">添加新会员</i></a>

							&nbsp;&nbsp;&nbsp;
							<a class="btn btn-primary" href="{:U('Member/lists')}?clear=1" id="add_right">强制刷新</i></a>							
						</div>&nbsp;&nbsp;&nbsp;
						<ol class="breadcrumb" style="height:55px;background-color: #ffffff;">							
							<li><i class="fa fa-warning"></i><a href="#">操作提示：</a></li><br/>	
							<li><font style="font-size:8px;color:#888;">通过会员管理，你可以进行查看、编辑会员资料等操作
							你可以根据条件搜索会员，然后选择相应的操作！</font></li>							
						</ol>
						<div class="panel-body">
							<!--搜索 开始-->
							<form method="get" name="formSearch" id="formSearch">
							
				               <div class="col-md-12" style="background-color:#f5f5f5;padding:0;">
								<div class="form-group" style="width:70%;">
				                    <div class="col-xs-2">
										<select name="search_name" class="form-control">
										  <option value="username">会员</option>
										   <option value="mobile">手机号码</option>
										   <option value="realname">真实姓名</option>
										</select>
				                    </div>
				                    <div class="col-xs-4">
				                        <input type="text" id="username" name="username" class="form-control" placeholder="">
				                    </div>
				                    <div class="col-xs-2">
											<select name="search_status" class="form-control">
											  <option selected="selected" value="-1">会员状态</option>
											  <option value="0">未开通</option>
											  <option value="1">已开通</option>
											  <option value="2">休眠</option>
											  <option value="3">冻结</option>
											</select>
				                    </div>
				                    <div class="col-xs-2">
										<select name="search_grade" class="form-control">
										  <option value="-1">会员级别</option>
										  <option value="0">普通会员</option>
										  <option value="1">银卡</option>
										  <option value="2">金卡</option>
										  <option value="3">钻卡</option>
										 </select>
				                    </div>
				                    <div class="col-xs-2">
										<button type="submit" class="btn btn-primary">搜索</button>
				                    </div>
				                </div>
				               </div>
				                    
							  </form>
							  <!--搜索 结束-->
							<table class="table table-striped table-bordered bootstrap-datatable datatable">
							  <thead>
								  <tr>
									  <th>ID</th>
                                      <th>会员账号</th>
									  <th class="title2">投资额度</th>
									  <th class="title2">静态积分</th>
									  <th class="title2">动态帐户</th>
<!-- 									  <th class="title2">排单币</th>
									  <th class="title2">激活码</th> -->
									  <th class="title2">消费帐户</th>
									  <th class="title2">会员等级</th>
									  <th class="title2">状态</th>
									  <th class="title2">操作</th>
								  </tr>
							  </thead>   
							  <tbody id="state">
								<volist name="list" id="vo">
								<tr>
									<td>{$vo.id}</td>
									<td class="wd">
										<p class="name" ><strong>{$vo.username}</strong>(真实姓名: {$vo.realname})</p>
										<p class="smallfont">注册时间:&nbsp;{$vo.createtime|date='Y-m-d',###}</p>
										<div style="font-size:13px;"><i class="fa fa-envelope-o"></i>&nbsp;&nbsp;{$vo.mobile}</div>
									</td>
									 <td class="align-center">{$vo.limit}</td>
									 <td class="align-center" style="color:red;">{$vo.integral1}</td>
									 <td class="align-center" style="color:red;">{$vo.integral2}</td>
<!-- 									 <td class="align-center" >{$vo.integral3}</td>
									 <td class="align-center" >{$vo.integral4}</td> -->
									 <td class="align-center" style="color:red;">{$vo.integral5}</td>
									<td class="align-center">
									<if condition="$vo.gotegary eq '0'">普通会员</if>
									<if condition="$vo.gotegary eq '1'">银卡</if>
									<if condition="$vo.gotegary eq '2'">金卡</if>
									<if condition="$vo.gotegary eq '3'">钻卡</if>									
									</td>
									<td class="align-center">
									<if condition="$vo.status eq '0'">未开通</if>
									<if condition="$vo.status eq '1'">已开通</if>
									<if condition="$vo.status eq '2'">休眠</if>
									<if condition="$vo.status eq '3'">冻结</if>									
									</td>
									<td class="align-center">
										<a class="label label-primary" role="button" data-toggle="modal" href="#edit" data-id="{$vo.id}" data-username="{$vo.username}" data-realname="{$vo.realname}" data-mobile="{$vo.mobile}" data-type="edit">修改</i>
										</a>
										
										<a href="#" data-id="{$vo.id}">			
										&nbsp;
										<if condition="$vo.status eq '3'">
										<span class="label label-info" data-status="2" >解冻</span>
										</if>
										<if condition="$vo.status eq '1'">
										<span class="label label-danger" data-status="3" >冻结</span>
										</if>
										<if condition="$vo.status eq '2'">
										<span class="label label-danger" data-status="3" >冻结</span>
										</if>
										<if condition="$vo.status eq '0'">
										<span class="label label-warning" data-status="1" >开通</span>
										</if>
										</a>
										
										<a href="#" data-id="{$vo.id}">					
										&nbsp;<span class="label label-success" data-cash="1">充值</span>
										</a>									
									 </td>

								</tr>
								</volist>
							  </tbody>
						  </table>  
							<ul class="pagination">
								{$page}
							 </ul>						  
						</div>
					</div>
				</div><!--/col-->
			
			</div><!--/row-->				
			
		<!-- end: Content -->
		<br><br><br>
		
	</div><!--/container-->
<!--添加新会员-->	
        <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="again" class="modal fade add_right">
		
            <div class="modal-dialog public-top"  id="">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="title">添加新会员</h4>
                    </div>
					<form action="{:U('Member/addUser')}" method="post" class="form-horizontal" id="action">
						<div class="modal-body">
							<label class="">会员账号:</label>
							<div class="">
								<input type="text" id="username2" name="username" value="" class="form-control placeholder-no-fix" >
							</div></br>
							<label class="">密码:</label>
							<div class="">
								<input type="password" id="password" name="password" class="form-control placeholder-no-fix" placeholder="不填，则默认密码为123456">
							</div></br>

							<label class="">手机号码:</label>
							<div class="">								
				                <input type="text" id="mobile" name="mobile" class="form-control placeholder-no-fix" >
				            </div></br>

							<label class="">真实姓名:</label>
							<div class="">								
				                <input type="text" id="realname" name="realname" class="form-control placeholder-no-fix" >
				            </div>
						</div></br>
						<input type="hidden"  name="id" id="id" value="">
						<input type="hidden"  name="type" id="type" value="user_add">
						<div class="modal-footer">
							<button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
							<button class="btn btn-primary mypost" type="sunmit">确认</button>
						</div>
					</form>	
              </div>
            </div>
        </div>		
</block>
<block name="script">
<script>
$("#add_right").click(function(){
	$(".add_right").attr('id','again');
	$("#action").attr('action',"{:U('Member/addUser')}");	
	$("#title").html('添加新会员');
	$("#username2").val('');
	$("#password").val('');
	$("#password").attr('placeholder','不填，则默认密码为123456');
	$("#mobile").val('');
	$("#realname").val('');
	$("#id").val('');
	$("#type").val('user_add');
	$("#username2").removeAttr("disabled");
});


$("#state tr td a").click(function(){

    var id = $(this).attr('data-id');
	var state = $(this).find('span').attr('data-status');
	
	var type = $(this).attr('data-type');
	var username = $(this).attr('data-username');
	var mobile = $(this).attr('data-mobile');
	var realname = $(this).attr('data-realname');
	
	if (type=='edit'){			
		$(".add_right").attr('id',type);
		$("#action").attr('action',"{:U('Member/editUser')}");		
		$("#title").html('修改导航程序');
		$("#username2").attr("disabled",'true');
	}
	
	
	if (id && type) {
		$("#title").html('修改会员信息');
		$("#username2").val(username);
		$("#password").attr('placeholder','不填，则密码不变');
		$("#mobile").val(mobile);
		$("#realname").val(realname);
		$("#id").val(id);
		$("#type").val('user_edit');		
	}
	
	if (id && !type) {
		$.ajax({
			url:"{:U('Member/editUser')}",
			data:{id:id,state:state},
			type:'post',
			dataType:'json',
			success:function (e) {			
			//alert(id);
				if (e.info==1) {
					alert('开通成功');
					location.reload();
				}if (e.info==2) {
					alert('解冻成功');
					location.reload();
				} else if(e.info==3){
					alert('冻结成功');
					location.reload();
				} else if(e.info==4){
					alert('修改失败');
				} 
			
			}
		});	
	}  

});
</script>
</block>	









